<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>类似call()和apply()方法可以将this引用到任何对象</title>
</head>

<body>
    <h2>JavaScript <b>this</b> 关键字</h2>
    <p>实例中，<b>this</b> 指向了 <b>person</b> 对象。</p>
    <p>因为 person 对象是 fullName 方法的所有者。</p>
    <p id="demo"></p>
    <script>
        // 创建一个对象
        var person = {
            firstName: "John",
            lastName: "Doe",
            id: 5566,
            fullName: function () {
                return this.firstName + " " + this.lastName;
            }
        };

        // 显示对象的数据
        document.getElementById("demo").innerHTML = person.fullName();
    </script>
</body>

</html>